
#include "sl_mm_signal.h"
#include "sl_types.h"
#include "sl_jittery.h"

void sl_mm_signal_init(mm_signal_t *mm_signal, const BYTE *map_addr)
{
	mm_signal->pMap_addr = map_addr;
	sl_jittery_init(&(mm_signal->jittery));
}

void sl_mm_signal_exit()
{

}

void sl_mm_signal_read(mm_signal_t *mm_signal)
{
sl_jittery_set_sample(&(mm_signal->jittery),(WORD)(*(mm_signal->pMap_addr)));
}
	

WORD sl_mm_signal_get_switch_signal(mm_signal_t *mm_signal) 
{
	return sl_jittery_get_effective_value(&(mm_signal->jittery));
}

LEVEL sl_mm_signal_get_switch_signal_by_pin(mm_signal_t *mm_signal, BYTE pin)
{
	if(pin>7)
		return LOWLEVEL;
	else
	{
		if(sl_jittery_get_effective_value(&(mm_signal->jittery))&(1<<pin))
			return HIGHLEVEL;
		else
			return LOWLEVEL;
	}

}

